<div id="assets">
  <p>
    <%= cms_icon 'picture_add.png' %> <%= link_to t('assets.actions.index.new'), new_cms_asset_path %>
  </p>

  <% if @cms_assets.empty? %>
    <p><%= t 'assets.actions.index.none' %></p>
  <% else %>
    <% if @cms_assets.any?(&:image?) %>
    <p class="preview"><%= link_to_function 'Toggle image previews', "asset_preview_toggle()" %></p>
    <% end %>

    <ul>
      <% @context_asset_tags.each do |tag| %>
        <li class="group tagged">
          <h4><%= tag.to_s %> <%= link_to cms_icon('picture_add.png', :title => 'Add a new asset with this tag'), new_cms_asset_path(:tag => tag.to_s) %></h4>
          <ul>
            <%= render :partial => 'cms/assets/asset', :collection => @context.assets.tagged_with(tag).ordered %>
          </ul>
        </li>
      <% end %>
      <li class="group untagged">
        <% unless @context_asset_tags.blank? %>
        <h4>Untagged</h4>
        <% end %>
        <ul>
          <%= render :partial => 'cms/assets/asset', :collection => @context.assets.untagged.ordered %>
        </ul>
      </li>
    </ul>
  <% end %>
</div>
